<%@page contentType="text/html" pageEncoding="UTF-8" import="java.io.*, java.sql.*, javax.sql.*"%>
<%
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("Expires", -1);
    Connection con = com.elookinto.wordlist.Util.getCon();
    String uid = (String) session.getAttribute("uid");
    if (uid == null) {
        return;
    }
    PreparedStatement st = con.prepareStatement("Select distinct listname  from wordlist where uid=? order by listname");
    st.setString(1, uid);
    out.println("Lists from User: " + uid + "<br/>");
    ResultSet rs = st.executeQuery();
    while (rs.next()) {
        String listName = rs.getString("listname");
        //System.out.println(rs.getDate("insert_time"));
        //System.out.println(rs.getString("listname"));
        //System.out.println(rs.getString("uid"));
        //System.out.println(word);
%>

<a  class="droppable" title="Right-click to rename the list" style="margin-left:5px" href="javascript:void(0)" onclick=" wordList('<%= listName%>', false)"><%= listName%></a>

<%}%>
<br/>
<a style="margin-left:5px" href="javascript:void(0)" onclick=" wordList(1)" > Today's New Words </a>
<a style="margin-left:5px" href="javascript:void(0)" onclick=" wordList(7)" > Past Week's New Words </a>
<a style="margin-left:5px" href="javascript:void(0)" onclick=" wordList(30)" > Past Month's Words </a>
<%
    rs.close();
    st.close();
    con.close();
%>

<script>

    $(".droppable").contextMenu({
        menu: 'renameList'
    },
    function(action, el, pos) {
       
         listName = $(el).text();
         $("#oldListName").text(listName);
         $( "#dialog-form" ).dialog( "open" );
        /*
        $.post("renameList.jsp", {listName:listName,wordList:$(el).text()}, function(data){
            //alert("Saved " + ui.draggable.text());
            //$('#message').css('display', 'block'); 
            $("#message").text("Saved '" + $(el).text() + "' to list " + listName +"!");
        });*/
    });
    
</script>